// 泛型(Generics)
export {}

function createNumberArray(length: number, value: number): number[]{
    const arr = Array<number>(length).fill(value)
    return arr
}
function createStringArray(length: number, value: string): string[]{
    const arr = Array<string>(length).fill(value)
    return arr
}
function createArray<T>(length: number, value: T): T[]{
    const arr = Array<T>(length).fill(value)
    return arr
}
const res = createNumberArray(3, 1000)
console.log(res)//=> [1000, 1000, 1000]


const res1 = createArray<string>(4, '200')
console.log(res1)


































